import "package:flutter/material.dart";
import "package:flutter/cupertino.dart"; //配置路由跳转动画，统一为左右切换

// import "../pages/homePage.dart"; //首页
// import "../pages/searchPage.dart"; //搜索页
// import "../pages/formPage.dart"; //表单页
// import "../pages/paramsPage.dart"; //传参页
// import "../pages/dialogPage.dart"; //弹窗页
// import "../pages/scrollPage.dart"; //滚动页
// import "../pages/animatedListPage.dart"; //动画列表
// import "../pages/pageViewPage.dart"; //pageView页
// import "../pages/tabBarViewPage.dart"; //tabBarView页
// import "../pages/customScrollViewPage.dart"; //customScrollViewPage页
// import "../pages/nestedScrollViewPage.dart"; //
// import "../pages/listenerPage.dart";
// import "../pages/animationPage.dart";
import '../_pages/appTabBottomBar.dart'; //初始页
import "../_pages/video.dart"; //视频页

Map routes = {
  "/": (context) => const AppTabBottomBar(),
  "/video": (context, {arguments}) => Video(arguments: arguments),
  // "/": (context) => const HomePage(), //“/”表示首页地址
  // "/search": (context) => const SearchPage(),
  // // {arguments}会接受到命名式路由导航的传入的Map类型参数，根据页面参数格式传入对应参数
  // "/form": (context, {arguments}) => FormPage(
  //       arguments: arguments,
  //     ),
  // // {arguments}会接受到命名式路由导航的传入的Map类型参数，根据页面参数格式传入对应参数
  // "/params": (context, {arguments}) => ParamsPage(
  //       params: arguments['params'],
  //     ),
  // "/dialog": (context) => const DialogPage(),
  // '/scroll': (context) => ScrollPage(),
  // "/animatedList": (context) => const AnimatedListPage(),
  // "/pageView": (context) => const PageViewPage(),
  // "/tabBarView": (context) => const TabBarViewPage(),
  // "/customScrollView": (context) => const CustomScrollViewPage(),
  // "/nestedScrollView": (context) => const NestedScrollViewPage(),
  // "/listener": (context) => const ListenerPage(),
  // "/animation": (context) => const AnimationPage(),
};

var onGenerateRoute = (RouteSettings settings) {
  // settings.name//路由名称
  // settings.arguments//路由参数
  // 是 Navigator.pushNamed(context,'name',arguments:{}) 中传入的name和arguments
  final String? name = settings.name;
  final Function? pageContentBuilder =
      routes[name]; //routes对应的函数 (context) => const HomePage()
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      // final Route route = MaterialPageRoute(
      //     builder: (context) =>
      //         pageContentBuilder(context, arguments: settings.arguments));
      final Route route = CupertinoPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      // final Route route =
      //     MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      final Route route =
          CupertinoPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};
